/***********************************************************************
 * Module:  Faktura.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class Faktura
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class Faktura implements Serializable {
	
	protected Integer id;
	protected int maticniBroj;
	protected Date rokPlacanjaFakture;
	protected Date datumIzdavanjaFakture;
	protected Date datumPrometaFakture;
	protected int redniBrojFakture;
	protected int verzija;

	protected Collection<Otpremnica> otpremnice;

	public Collection<Otpremnica> getOtpremnice() {
		if (otpremnice == null)
			otpremnice = new HashSet<Otpremnica>();
		
		return otpremnice;
	}

	public Iterator<Otpremnica> getIteratorOtpremnice() {
		if (otpremnice == null)
			otpremnice = new HashSet<Otpremnica>();
		
		return otpremnice.iterator();
	}

	public void setOtpremnice(Collection<Otpremnica> newOtpremnice) {
		removeAllOtpremnice();
		for (Iterator<Otpremnica> iter = newOtpremnice.iterator(); iter.hasNext();)
			addOtpremnica((Otpremnica) iter.next());
	}

	public void addOtpremnica(Otpremnica newOtpremnica) {
		if (newOtpremnica == null)
			return;
		if (this.otpremnice == null)
			this.otpremnice = new HashSet<Otpremnica>();
		if (!this.otpremnice.contains(newOtpremnica))
			this.otpremnice.add(newOtpremnica);
	}

	public void removeOtpremnica(Otpremnica oldOtpremnica) {
		if (oldOtpremnica == null)
			return;
		if (this.otpremnice != null)
			if (this.otpremnice.contains(oldOtpremnica))
				this.otpremnice.remove(oldOtpremnica);
	}

	public void removeAllOtpremnice() {
		if (otpremnice != null)
			otpremnice.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getMaticniBroj() {
		return maticniBroj;
	}

	public void setMaticniBroj(int maticniBroj) {
		this.maticniBroj = maticniBroj;
	}

	public Date getRokPlacanjaFakture() {
		return rokPlacanjaFakture;
	}

	public void setRokPlacanjaFakture(Date rokPlacanjaFakture) {
		this.rokPlacanjaFakture = rokPlacanjaFakture;
	}

	public Date getDatumIzdavanjaFakture() {
		return datumIzdavanjaFakture;
	}

	public void setDatumIzdavanjaFakture(Date datumIzdavanjaFakture) {
		this.datumIzdavanjaFakture = datumIzdavanjaFakture;
	}

	public Date getDatumPrometaFakture() {
		return datumPrometaFakture;
	}

	public void setDatumPrometaFakture(Date datumPrometaFakture) {
		this.datumPrometaFakture = datumPrometaFakture;
	}

	public int getRedniBrojFakture() {
		return redniBrojFakture;
	}

	public void setRedniBrojFakture(int redniBrojFakture) {
		this.redniBrojFakture = redniBrojFakture;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}